package com.atguigu4.search_sort.exer3;

import java.util.HashMap;
import java.util.Map;

/**
 * @author NoobMaster69  * @date 2024/5/27 0027 星期一 19:22
 */
class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0;i < nums.length;i++){
            int com = target - nums[i];
            if(map.containsKey(com)){
                return new int[]{i,map.get(com)};
            }
            map.put(nums[i],i);
        }
        return new int[]{};
    }
}